<div class="dtree">
	<?php
		$footers = getFooters();
		if($footers)
		{
			echo ' <script type="text/javascript"> ';
			echo ' d = new dTree(\'d\'); ';
			echo ' d.add(0,-1,\'Component Footers\',\'?con='.$_REQUEST['con'].'\',\'\',\'\',\'img/globe.gif\',\'img/globe.gif\'); ';
			echo ' d.add(1,0,\'All Footers ('.count($footers).')\',\'?con='.$_REQUEST['con'].'\', \'\',\'\',\'img/folder.gif\'); ';
			$j=2;
			foreach($footers as $footer)
			{
				echo ' d.add('.$j.',1,\''.$footer['name'].'\',\'?con='.$_REQUEST['con'].'&amp;item='.$footer['id'].'\',\'\',\'\',\'img/imgfolder.gif\',\'img/imgfolder.gif\'); ';
				if(($footers['id'] == $_REQUEST['item']))
				{ $openTo = ($j); }
				$j++;
			}
			foreach($hfbcats as $hfbcat)
			{
				$catItems = getHFBCatItems($hfbcat['id'], 2);
				echo ' d.add('.$j.',0,\''.$hfbcat['title'].' ('.count($catItems).') '.'\',\'?con='.$_REQUEST['con'].'&amp;cat='.$hfbcat['id'].'\',\'\',\'\',\'img/folder.gif\',\'img/folder.gif\'); ';
				if(($_REQUEST['cat'] > 0) && ($hfbcat['id'] == $_REQUEST['cat']))
				{ $openTo = ($j); }
				$parent = $j;
				$j++;
				
				if($catItems)
				{
					foreach($catItems as $catItem)
					{
						foreach($footers as $footer)
						{
							if($footer['id'] == $catItem['item_id'])
							{
								echo ' d.add('.$j.','.$parent.',\''.$footer['name'].'\',\'?con='.$_REQUEST['con'].'&amp;cat='.$hfbcat['id'].'&amp;item='.$footer['id'].'\',\'\',\'\',\'img/imgfolder.gif\',\'img/imgfolder.gif\'); ';
								if(($_REQUEST['cat'] > 0) && ($hfbcat['id'] == $_REQUEST['cat']) && ($footer['id'] == $_REQUEST['item']))
								{ 
									$openTo = ($j); 
									$cat = $parent;
								}
								$j++;
							}
						}
					}
				}
			}
			echo ' document.write(d); ';
			if($openTo > 0)
			{ echo ' d.openTo('.$openTo.', true); '; }
			echo ' </script> ';
		}
	?>
</div>